package com.yzd.learnjava.enumerated;

import java.util.EnumSet;

import com.yzd.learnjava.util.Print;

public class CarWash {
	public enum Cycle{
		UNDERBODY{
			void action() {
				Print.print("Spraying the underbody");
			}
		}, 
		WHEELWASH{
			void action() {
				Print.print("Washing the wheels");
			}
		},
		PREWASH{
			void action() {
				Print.print("Loosening the dirt");
			}
		},
		BASIC{
			void action() {
				Print.print("The basic wash");
			}
		},
		HOTWAX{
			void action() {
				Print.print("Applying hot wax");
			}
		}, 
		RINSE{
			void action() {
				Print.print("Rinseing");
			}
		},
		BLOWDRY{
			void action() {
				Print.print("Blowing dry");
			}
		};
		abstract void action();
	}
	
	EnumSet<Cycle> cs = EnumSet.of(Cycle.BASIC, Cycle.RINSE);
	public void add(Cycle c) {
		cs.add(c);
	}
	public void washCar() {
		for(Cycle c : cs) {
			c.action();
		}
	}
	public String toString() {
		return cs.toString();
	}
	
	public static void main(String[] args) {
		CarWash carWash = new CarWash();
		Print.print(carWash);
		carWash.washCar();
		
		
		carWash.add(Cycle.BLOWDRY);
		carWash.add(Cycle.BLOWDRY);
		carWash.add(Cycle.RINSE);
		carWash.add(Cycle.HOTWAX);
		Print.print(carWash);
		carWash.washCar();
	}
}















